package com.haolp.sys;

import com.haolp.sys.pojo.DefaultCache;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;

import javax.sql.DataSource;
import java.sql.SQLException;

@SpringBootTest
class DbTravelSysDbApplicationTests {
    @Autowired
    public DbTravelSysDbApplicationTests(ApplicationContext act, DataSource dataSource) {
        this.act = act;
        this.dataSource = dataSource;
    }

    //@Autowired
    ApplicationContext act;
    // @Autowired
    DataSource dataSource;
    @Test
    public void testDataSource() throws SQLException {
        System.out.println(dataSource.getClass());
        System.out.println(dataSource.getConnection());
    }
    @Test
    public void testIOC() {
        //若输出结果说明
        //启动springboot的时候，默认初始化了ApplicationContext对象
        System.out.println(act);
    }
    @Test
    public void testDefaultCache() {
        DefaultCache bean = act.getBean(DefaultCache.class);
        bean.sayHello();
        System.out.println(bean+"====");
    }


}